﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Query;
using Microsoft.Xrm.Sdk.Messages;
using Xrm.Framework.Test.Integration;


namespace Xrm.Solutions.FrameworkSample.XrmIntegrationTests.Plugins
{
    [TestClass]
    public class TestPreValidateContactCreate : PluginIntegrationTest
    {
        #region Instance Variables

        #endregion

        #region Setup

        protected override OrganizationRequest SetupTriggerRequest()
        {
            Entity contact = new Entity("contact");
            contact["firstname"] = "John";
            contact["birthdate"] = DateTime.Now;

            CreateRequest request = new CreateRequest();
            request.Target = contact;
            return request;
        }

        #endregion

        #region Test

        [TestMethod]
        public void RunTestPreValidateContactCreate()
        {
            base.Test();
        }

        #endregion

        #region Verify

        protected override void Verify()
        {
            Assert.IsNotNull(Error);

            Assert.IsTrue(Error.Message.Contains("lastname"));
        }

        #endregion
    }
}
